package org.sample.algorithm.sort;

public class BubbleSort {

    public static int[] sort(int[] array) {
        int temp;
        for (int i = 0; i < array.length - 1; i++) {
            boolean ordered = true;
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j] > array[j + 1]) {
                    ordered = false;
                    temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
            if (ordered)
                break;
        }
        return array;
    }

}